<?php
$this->title = $model['title'];
$this->registerMetaTag(["name" => "keywords", "content" => "{$model['keywords']}"]);
$this->registerMetaTag(["name" => "description", "content" => "{$model['description']}"]);
?>

<?php
use common\Yii01;
use frontend\models\CommentForm;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\bootstrap\Alert;
?>
<div class="main pd20 mb20" style="position:relative;">
    <div class="row gbook_box" style="border:none; background:none;">

        <!-- 点赞双箭头 -->
        <div class="col-xs-1">
            <div class="midcol unvoted" style="text-align: center">
                <a href="javascript:;" class="<?php if(\common\Yii01::postZC(Yii::$app->request->getUserIP(),$model['id'],0)):?>active<?php endif?> zan"><b class="glyphicon glyphicon-chevron-up "></b><br/><span class="num"><?=$model['zan']?></span> <i style="display: none"><?=$model['id']?></i></a>
                <a href="javascript:;" class="<?php if(Yii01::postZC(Yii::$app->request->getUserIP(),$model['id'],1)):?>active<?php endif?> cai"><span class="num"><?=$model['cai']?></span><br/> <b class="glyphicon glyphicon-chevron-down"></b><i style="display: none"><?=$model['id']?></i></a>
            </div>
        </div>
        <!-- 点赞双箭头 -->
        <div class="col-sm-11 fx_left1">


            <div class="media">
                <div class="media-left">
                    <a class="replyuserhead"  data-toggle="popover" data-trigger="focus" data-html="true" data-content='<img src="<?=Yii::$app->urlManager->baseUrl.'/'.$model['img']?>" width="100" height="100">'>
                        <img class="media-object img-rounded" src="<?=Yii::$app->urlManager->baseUrl.'/'.$model['img']?>" width="50px" height="50px" alt="作者头像">
                    </a>
                </div>
                <div class="media-body ">
                    <h4>
                        <a href="<?= Yii::$app->urlManager->createUrl(['post/view','id'=>$model['id']])?>" class="" title="<?=$model['title']?>"><?=$model['title']?></a>
                        <?php if($model['type'] == 3):?>
                            <span style="color: #666;font-size: 13px"><?=Yii01::getUrl($model['url'])?></span>
                        <?php endif?>
                    </h4>

                    <div class="gbook_list">
                        <a href="javascript:;" target="_blank" title="<?=$model['nickname']?>" class="nickname"><?=$model['nickname']?>(<b style='color: red'>PO主</b>)</a>&nbsp;&nbsp;<?=$model['signature']?>&nbsp;&nbsp;发表于<?=date("Y-m-d H:i:s",$model['create_at'])?>
                    </div>
                    <div class="content single">
                        <?php if(!empty($model['thumb']) && $model['type'] == 2):?>
                        <p class="text-justify"><img class="img" src="<?=Yii::$app->urlManager->baseUrl.'/'.$model['thumb']?>" alt="<?=$model['title']?>"/></p>
                        <?php endif?>
                        <p class="text-justify"><?=$model['content']?></p>
                    </div>
                    <div class="btn-group fl" role="group" aria-label="...">
                        <?php if(Yii::$app->user->can('admin_login') || Yii01::isManager(Yii::$app->user->id,$model['cate_id'])):?>
                        <?= Html::a('<span class="glyphicon glyphicon-trash"></span>删除', ['delete', 'id' => $model['id']], [
                            'class' => 'btn btn-default btn-sm',
                            'data' => [
                                'confirm' => '你确定要删除这篇帖子吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                        <?php endif?>
                        <button type="button" class="btn btn-default btn-sm collect">
                            <span class="glyphicon glyphicon-heart-empty"></span>
                            收藏
                            <i style="display: none"><?=$model['id'] ?></i>
                        </button>
                        <button type="button" class="btn btn-default btn-sm report">
                            <span class="glyphicon glyphicon-trash"></span>
                            举报
                            <i style="display: none"><?=$model['id'] ?></i>
                        </button>
                        <?php if($model['type'] == 2): ?>
                            <a class="btn btn-default btn-sm" target="_blank" href="http://www.wmorz.com/<?= $model['thumb']?>">查看图片</a>
                        <?php elseif($model['type'] == 3):?>
                            <a class="btn btn-default btn-sm" target="_blank" href="<?= $model['url']?>">查看链接</a>
                        <?php endif ?>

                    </div>

                    <div class="small text-right">
                        <span class="glyphicon glyphicon-eye-open"></span> <?=$model['view']?>次浏览&nbsp;&nbsp;
                        <span class="glyphicon glyphicon-comment"></span> <?=Yii01::getComments($model['id'])?>次讨论&nbsp;&nbsp;
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 富文本编辑器 -->
    <a href="javascript:;" name="comment"></a>
    <?php $form =  ActiveForm::begin(['id'=>'comment-form'])?>
    <script id="container" name="CommentForm[content]"></script>
    <?= $form->field(new CommentForm(),'post_id')->hiddenInput(['value'=>$model['id']])->label(false)?>
    <div class="form-group">
        <div class="row">
            <div class="col-xs-2 col-xs-offset-10">
                <?=Html::Button("提交",['class'=>'btn btn-success btn-block','id'=>'comment-btn'])?>
            </div>

        </div>
    </div>
    <?php ActiveForm::end()?>
    <!-- 富文本编辑器结束 -->

</div>


<div class="main">
    <!-- Nav tabs -->
    <div role="tabpanel" style="position:relative;">

        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" <?php if(!in_array($type,[1,2,3])) :?>class="active" <?php endif?> ><a href="<?=Yii::$app->urlManager->createUrl(['post/view','id'=>$model['id']])?>">热&nbsp;门</a>
            </li>
            <li role="presentation"  <?php if($type == 1) :?>class="active" <?php endif?> ><a href="<?=Yii::$app->urlManager->createUrl(['post/view','type'=>'1','id'=>$model['id']])?>">最&nbsp;新</a>
            </li>
            <li role="presentation" <?php if($type == 2) :?>class="active" <?php endif?> ><a href="<?=Yii::$app->urlManager->createUrl(['post/view','type'=>'2','id'=>$model['id']])?>">最&nbsp;旧</a>
            </li>
            <li role="presentation" <?php if($type == 3) :?>class="active" <?php endif?> ><a href="<?=Yii::$app->urlManager->createUrl(['post/view','type'=>'3','id'=>$model['id']])?>">具有争议</a></li>
        </ul>


        <!-- Tab panes -->
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="one01">
                <div id="comment-content">
                    <div class="main">
<?php if(!empty($comment)) :?>
                        <?php Yii01::traverseArray($comment,$uid)?>
    <?php  else :?>
    <?php
    Alert::begin([
        'options' => [
            'class' => 'alert-warning',
        ],
    ]);

    echo "<center><h1>沙发空缺中，还不快抢～</h1></center>";

    Alert::end();

    ?>

<?php endif?>
                    </div>

                </div>
            </div>


        </div>

    </div>
    <!-- Nav tabs -->
</div>




<?php $this->registerJsFile("@web/ueditor/ueditor.config.js"); ?>
<?php $this->registerJsFile("@web/ueditor/ueditor.all.min.js"); ?>
<?php
$script = <<<UM
jQuery(document).ready(function($) {
    var ue = UE.getEditor('container', {
        toolbars: [
            ['fullscreen', 'bold','italic','underline','strikethrough','justifyleft','justifyright','justifycenter','insertunorderedlist','insertorderedlist', 'spechars', 'emotion','insertimage','insertvideo','music','insertcode','fontfamily', ]
        ],
        initialFrameHeight:150
    });
    ue.ready(function() {
        //设置编辑器的内容
      //  ue.setContent('请输入评论内容');
    });


});

UM;
$this->registerJs($script);
?>